<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 方法：1.提高代码重用性  2.2000（5-6）长代码使用方法变成短代码 -->
    <div id="app">
        <my-first></my-first>
        

    </div>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        var MySecond = {
            template: `
                <div>这是子组件</div>
            `
        }
        //局部注册
        var MyFirst = {
            //template:模板
            template: `
                <div>
                {{msg}}    
                <button @click="++num">点击{{num}}</button>
                <my-second></my-second>
                </div>
            `,
            data: function () {
                return {
                    msg: 'hello',
                    num: 0
                }
            },
            //生命周期 侦听器，计算属性，方法，状态 都有

            //components
            //子组件
            components: {
                //组件名:对象
                //MySecond:MySecond
                MySecond

            }
        }

        var app = Vue.createApp({
            data: function () {
                return {
                }
            },
        })
        //component(组件名,{}):组件
        //1.最好是两个单词组合起来，大驼峰的形式


        /* 全局组件的注册 */
        app.component('MyFirst', MyFirst);
        
        app.mount('#app');
    </script>
</body>

</html>